home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / GIMP 2.6.8 / gimp-2.6.8-i686-setup.exe / {app} / share / gimp / 2.0 / scripts / blended-logo.scm < prev    next >
Text File  |  2009-12-15  |  8KB  |  201 lines

  1. ;  BLENDED-DROP-SHADOW-LOGO
  2. ;  draw the specified text over a blended background using current gimp fg
  3. ;   and bg colors.  The finished blend has a drop shadow underneath that blends
  4. ;   to the specified bg-color
  5. ;  if the blend colors are specified as high intensity, the sharp option
  6. ;   should be enabled or the logo will come out blurry
  7.  
  8. (define (blended-logo-scale size percent)
  9.   (* size percent)
  10. )
  11.  
  12. (define (apply-blended-logo-effect img
  13.                                    logo-layer
  14.                                    b-size
  15.                                    bg-color
  16.                                    blend-mode
  17.                                    blend-fg
  18.                                    blend-bg
  19.                                    blend-gradient
  20.                                    blend-gradient-reverse)
  21.   (let* (
  22.         (b-size-2 (blended-logo-scale b-size 0.5))
  23.         (f-size (blended-logo-scale b-size 0.75))
  24.         (ds-size (blended-logo-scale b-size 0.5))
  25.         (ts-size (- b-size-2 3))
  26.         (width (car (gimp-drawable-width logo-layer)))
  27.         (height (car (gimp-drawable-height logo-layer)))
  28.         (blend-layer (car (gimp-layer-new img
  29.                                           width height RGBA-IMAGE
  30.                                           "Blend" 100 NORMAL-MODE)))
  31.         (shadow-layer (car (gimp-layer-new img
  32.                                            width height RGBA-IMAGE
  33.                                            "Shadow" 100 NORMAL-MODE)))
  34.         (text-shadow-layer (car (gimp-layer-new img
  35.                                                 width height RGBA-IMAGE
  36.                                                 "Text Shadow" 100 MULTIPLY-MODE)))
  37.         (tsl-layer-mask (car (gimp-layer-create-mask text-shadow-layer
  38.                                                      ADD-BLACK-MASK)))
  39.         (drop-shadow-layer (car (gimp-layer-new img
  40.                                                 width height RGBA-IMAGE
  41.                                                 "Drop Shadow" 100 MULTIPLY-MODE)))
  42.         (dsl-layer-mask (car (gimp-layer-create-mask drop-shadow-layer
  43.                                                      ADD-BLACK-MASK)))
  44.         )
  45.  
  46.     (script-fu-util-image-resize-from-layer img logo-layer)
  47.     (script-fu-util-image-add-layers img text-shadow-layer drop-shadow-layer blend-layer shadow-layer)
  48.     (gimp-image-raise-layer img text-shadow-layer)
  49.     (gimp-selection-none img)
  50.     (gimp-edit-clear text-shadow-layer)
  51.     (gimp-edit-clear drop-shadow-layer)
  52.     (gimp-edit-clear blend-layer)
  53.     (gimp-context-set-background bg-color)
  54.     (gimp-drawable-fill shadow-layer BACKGROUND-FILL)
  55.     (gimp-rect-select img b-size-2 b-size-2 (- width b-size) (- height b-size) CHANNEL-OP-REPLACE TRUE b-size-2)
  56.     (gimp-context-set-background '(0 0 0))
  57.     (gimp-edit-fill shadow-layer BACKGROUND-FILL)
  58.     (gimp-selection-layer-alpha logo-layer)
  59.     (gimp-layer-add-mask text-shadow-layer tsl-layer-mask)
  60.     (gimp-context-set-background '(255 255 255))
  61.     (gimp-edit-fill tsl-layer-mask BACKGROUND-FILL)
  62.     (gimp-selection-feather img f-size)
  63.     (gimp-context-set-background '(63 63 63))
  64.     (gimp-edit-fill drop-shadow-layer BACKGROUND-FILL)
  65.     (gimp-context-set-background '(0 0 0))
  66.     (gimp-edit-fill text-shadow-layer BACKGROUND-FILL)
  67.     (gimp-context-set-foreground '(255 255 255))
  68.  
  69.     (gimp-edit-blend text-shadow-layer FG-BG-RGB-MODE NORMAL-MODE
  70.                      GRADIENT-SHAPEBURST-ANGULAR 100 0 REPEAT-NONE FALSE
  71.                      FALSE 0 0 TRUE
  72.                      0 0 1 1)
  73.  
  74.     (gimp-selection-none img)
  75.     (gimp-context-set-foreground blend-fg)
  76.     (gimp-context-set-background blend-bg)
  77.     (gimp-context-set-gradient blend-gradient)
  78.  
  79.     (gimp-edit-blend blend-layer blend-mode NORMAL-MODE
  80.                      GRADIENT-LINEAR 100 0 REPEAT-NONE blend-gradient-reverse
  81.                      FALSE 0 0 TRUE
  82.                      0 0 width 0)
  83.  
  84.     (gimp-layer-translate logo-layer (- b-size-2) (- b-size-2))
  85.     (gimp-layer-translate blend-layer (- b-size) (- b-size))
  86.     (gimp-layer-translate text-shadow-layer (- ts-size) (- ts-size))
  87.     (gimp-layer-translate drop-shadow-layer ds-size ds-size)
  88.     (gimp-selection-layer-alpha blend-layer)
  89.     (gimp-layer-add-mask drop-shadow-layer dsl-layer-mask)
  90.     (gimp-context-set-background '(255 255 255))
  91.     (gimp-edit-fill dsl-layer-mask BACKGROUND-FILL)
  92.     (gimp-layer-remove-mask drop-shadow-layer MASK-APPLY)
  93.     (gimp-selection-none img)
  94.   )
  95. )
  96.  
  97. (define (script-fu-blended-logo-alpha img
  98.                                       logo-layer
  99.                                       b-size
  100.                                       bg-color
  101.                                       blend-mode
  102.                                       blend-fg
  103.                                       blend-bg
  104.                                       blend-gradient
  105.                                       blend-gradient-reverse)
  106.   (begin
  107.     (gimp-context-push)
  108.  
  109.     (gimp-image-undo-group-start img)
  110.     (apply-blended-logo-effect img logo-layer b-size bg-color
  111.                                blend-mode blend-fg blend-bg
  112.                                blend-gradient blend-gradient-reverse)
  113.     (gimp-image-undo-group-end img)
  114.     (gimp-displays-flush)
  115.  
  116.     (gimp-context-pop)
  117.   )
  118. )
  119.  
  120.  
  121. (script-fu-register "script-fu-blended-logo-alpha"
  122.     _"Blen_ded..."
  123.     _"Add blended backgrounds, highlights, and shadows to the selected region (or alpha)"
  124.     "Spencer Kimball"
  125.     "Spencer Kimball"
  126.     "1996"
  127.     "RGBA"
  128.     SF-IMAGE      "Image"             0
  129.     SF-DRAWABLE   "Drawable"          0
  130.     SF-ADJUSTMENT _"Offset (pixels)"  '(15 1 100 1 10 0 1)
  131.     SF-COLOR      _"Background color" "white"
  132.     SF-OPTION     _"Blend mode"       '(_"FG-BG-RGB"
  133.                                         _"FG-BG-HSV"
  134.                                         _"FG-Transparent"
  135.                                         _"Custom Gradient")
  136.     SF-COLOR      _"Start blend"      '(22 9 129)
  137.     SF-COLOR      _"End blend"        '(129 9 82)
  138.     SF-GRADIENT   _"Gradient"         "Golden"
  139.     SF-TOGGLE     _"Gradient reverse" FALSE
  140. )
  141.  
  142. (script-fu-menu-register "script-fu-blended-logo-alpha"
  143.                          "<Image>/Filters/Alpha to Logo")
  144.  
  145.  
  146. (define (script-fu-blended-logo text
  147.                                 size
  148.                                 font
  149.                                 text-color
  150.                                 bg-color
  151.                                 blend-mode
  152.                                 blend-fg
  153.                                 blend-bg
  154.                                 blend-gradient
  155.                                 blend-gradient-reverse)
  156.   (let* (
  157.         (img (car (gimp-image-new 256 256 RGB)))
  158.         (b-size (blended-logo-scale size 0.1))
  159.         (text-layer (car (gimp-text-fontname img -1 0 0 text b-size TRUE size PIXELS font)))
  160.         )
  161.     (gimp-context-push)
  162.  
  163.     (gimp-image-undo-disable img)
  164.     (gimp-context-set-foreground text-color)
  165.     (gimp-layer-set-lock-alpha text-layer TRUE)
  166.     (gimp-edit-fill text-layer FOREGROUND-FILL)
  167.     (apply-blended-logo-effect img text-layer b-size bg-color
  168.                                blend-mode blend-fg blend-bg
  169.                                blend-gradient blend-gradient-reverse)
  170.     (gimp-image-undo-enable img)
  171.     (gimp-display-new img)
  172.  
  173.     (gimp-context-pop)
  174.   )
  175. )
  176.  
  177. (script-fu-register "script-fu-blended-logo"
  178.     _"Blen_ded..."
  179.     _"Create a logo with blended backgrounds, highlights, and shadows"
  180.     "Spencer Kimball"
  181.     "Spencer Kimball"
  182.     "1996"
  183.     ""
  184.     SF-STRING     _"Text"               "GIMP"
  185.     SF-ADJUSTMENT _"Font size (pixels)" '(150 2 1000 1 10 0 1)
  186.     SF-FONT       _"Font"               "Crillee"
  187.     SF-COLOR      _"Text color"         '(124 174 255)
  188.     SF-COLOR      _"Background color"   "white"
  189.     SF-OPTION     _"Blend mode"         '(_"FG-BG-RGB"
  190.                                           _"FG-BG-HSV"
  191.                                           _"FG-Transparent"
  192.                                           _"Custom Gradient")
  193.     SF-COLOR      _"Start blend"        '(22 9 129)
  194.     SF-COLOR      _"End blend"          '(129 9 82)
  195.     SF-GRADIENT   _"Gradient"           "Golden"
  196.     SF-TOGGLE     _"Gradient reverse"   FALSE
  197. )
  198.  
  199. (script-fu-menu-register "script-fu-blended-logo"
  200.                          "<Image>/File/Create/Logos")
  201.